home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / cdda_mpeg_op5 / arexx / PlayHifi.dopus5 < prev   
Text File  |  1995-12-30  |  9KB  |  312 lines

  1. /* Programm: PlayHifi.dopus5
  2. ** $VER: PlayHifi.dopus5 1.3 (10-Dec-95)
  3. ** 
  4. ** Needed: Directory Opus V5.xx (© by Jonathan Potter & GPSoftware)
  5. **         Play16 (© 1995 by Thomas Wenzel)
  6. **         mpega (© 1995 by Stephane Tavenard) or/and PeggyPlus MPEG-Card
  7. **         PlayADPCM (Autor Christian Buchner)
  8. **
  9. ** Copyright © 1995 Eckhard Ludwig (Eckhard@top.east.de)
  10. ** PlayHifi.dopus5 is copyrighted freeware. It may be distributed freely.
  11. **
  12. ** Call as:
  13. ** ------------------------------------------------------------------------------
  14. ** ARexx    DOpus5:ARexx/PlayHifi.dopus5 {Qp}
  15. ** ------------------------------------------------------------------------------
  16. ** Set all Attribut off.
  17. */
  18.  
  19. /*--------S E T T I N G S : -------------------------------------------*/
  20. /* If the file ENV:PlayHifi.PREFS exists, that one will override the   */
  21. /* settings here ...                                                   */
  22.  
  23. /*- Path to Player command --------------------------------------------*/
  24. Play16 = "C:Play16"
  25. PL16_OPTIONS=" Paula14 FILTER=OFF"
  26.  
  27. PlayADPCM = "C:PlayADPCM"
  28.  
  29. /*- Path to MPEGPlayer command ----------------------------------------*/
  30. PlayMPEG = "C:mpega"   /* Softwareplayer */
  31. MPEGA_OPTIONS=" -p -f0 -d2 -q2 "
  32. /*---------------------------------------------------------------------*/
  33.  
  34. Index  = 'T:PlayDOpus5Index.temp' /* Temporaere Titelliste */
  35. parse arg portname
  36. if portname='' then
  37.    portname='DOPUS.1'
  38. address value portname
  39.  
  40. options results
  41. options failat 21
  42. lf='0a'x
  43.  
  44. address command 'Delete >NIL: '||Index  /*falls Index in Benutzung, läuft Player bereits*/
  45.  
  46. if open(1,'env:PlayHifi.prefs','R') then do
  47.    do i=1 to 6
  48.     prefs.i = readln(1)
  49.         end
  50.    if prefs.2 ~="" then PLAY16=prefs.2
  51.    if prefs.3 ~="" then PlayADPCM=prefs.3
  52.    if prefs.4 ~="" then PlayMPEG=prefs.4
  53.    if prefs.5 ~="" then PL16_OPTIONS=prefs.5
  54.    if prefs.6 ~="" then MPEGA_OPTIONS=prefs.6
  55.    drop prefs.
  56.    call close(1)
  57.    end
  58.  
  59. if ~show('l','rexxsupport.library') then
  60.     call addlib('rexxsupport.library',0,-30,0)
  61.  
  62. /* init locale */
  63. if ~show(l,'locale.library') then
  64.         call addlib('locale.library',0,-30)
  65. if show(l,'locale.library') then
  66.         catalog=opencatalog('PlayHifi.catalog','english',0)
  67.  
  68. lister query source
  69. if rc>0 then do
  70.    dopus front
  71.    dopus request '"'getcatstr(0,'Error:'lf'No source selected')'"' getcatstr(1,'Quit')
  72.    exit
  73. end
  74.  
  75. parse var result handle 
  76.  
  77. lister query handle numselfiles
  78. if result=0 then do
  79.      dopus front
  80.      dopus request '"'getcatstr(2,'Error:'lf'No entry selected')'"' getcatstr(1,'Quit')
  81.      exit
  82. end
  83.  
  84. if exists(Index) then Index=Index||'1'
  85.    else Test2=1
  86.    
  87. if exists(Index) then call open('output',Index,'A')
  88.    else do
  89.       if open('output',Index,'w') ~=1 then do
  90.          dopus request '"'getcatstr(3,'Error:'lf'Load script in to editor and set path to Index !')'"' getcatstr(1,'Quit')
  91.          exit
  92.          end
  93.    end
  94.  
  95. lister set handle busy on
  96. lister query handle path
  97. QuellPfad=result
  98.  
  99. lister query handle selfiles stem files.
  100. lister set handle progress files.count getcatstr(4,'Scanning for Index...')
  101. lister refresh handle full  
  102.  
  103. do i=0 to files.count-1
  104.    lister query handle abort
  105.    if result then do
  106.     test=0
  107.     leave
  108.     end
  109.    lister set handle progress count i+1
  110.    lister set handle progress name files.i
  111.    Titel=Quellpfad||files.i
  112.    call DTTEST
  113.    if DT~=0 then do
  114.       lister query handle entry '"'files.i'"' stem fileinfo.
  115.       call writeln('output',Titel' @SIZE='fileinfo.size' @COMMENT='fileinfo.comment)
  116.       test=1
  117.       end
  118.    lister select handle '"'files.i'"' off
  119. end
  120. lister refresh handle full
  121. lister set handle busy off
  122. call close('output')
  123.  
  124. if Test2~=1 then do
  125.    if test=1 then do
  126.        dopus front 
  127.        dopus request '"'getcatstr(14,'Songs added to playlist')'"' 'OK'
  128.        end
  129.    exit
  130.    end
  131. if test ~=1 then do
  132.    address command 'Delete >NIL: '||Index
  133.    exit
  134.    end
  135.  
  136. lister new
  137. handle=result
  138. lister set handle title getcatstr(5,'Hifi Player')
  139. do forever
  140.  lister set handle sort date
  141.  call open('input2',Index,'R')
  142.  do i = 1 to 200
  143.    Zeile=readln('input2')
  144.    if Zeile="" then leave
  145.    SPOS=pos("@SIZE=",Zeile)
  146.    CPOS=pos("@COMMENT=",Zeile)
  147.    Titel=left(Zeile,SPOS-2)
  148.    if ~exists(Titel) then do
  149.      dopus front 
  150.      dopus request '"'getcatstr(8,'Error:'lf"'%s'"' not found !',Titel)'"' getcatstr(7,'Next')
  151.      iterate
  152.      end
  153.    call DTTEST
  154.    select
  155.     when DT="MP2" then MPEG=1
  156.     when DT="ADPCM3" then ADPCM=1
  157.     otherwise Play16DT=1
  158.    end
  159.    APOS=lastpos("/",Titel)
  160.    if APOS=0 then APOS=lastpos(":",Titel)   
  161.    songname=substr(Titel,APOS+1)
  162.    lister add handle '"'songname'" 'substr(Zeile,SPOS+6,CPOS-SPOS-6)' -1 'i' r 'substr(Zeile,CPOS+9)''
  163.    lister select handle '"'songname'"' on
  164.    lister set handle display name size comment
  165.  end
  166.  lister refresh handle full
  167.  call close ('input2')
  168.  
  169.  if MPEG=1 & ~show('P','Peggy') then do
  170.       if showlist("A","PEGGYPLUS")=1 then do
  171.         test=2
  172.     call pragma('STACK',8192)
  173.         address command 'RUN >NIL: <NIL: PEGGYPLUS:MPEGPlayer'
  174.         address command 'waitforport Peggy'
  175.         address value portname
  176.         dopus front
  177.         end
  178.       else do
  179.         if ~exists(PlayMPEG) then do
  180.           dopus front
  181.           dopus request '"'getcatstr(9,'Error:'lf'MPEG-Player not found !'lf'path to command: '"'%s'"'',PlayMPEG)'"' getcatstr(1,'Quit')
  182.       call Ende
  183.           end
  184.         end
  185.  end
  186.  if ADPCM=1 & ~exists(PlayADPCM) then do
  187.           dopus front
  188.           dopus request '"'getcatstr(10,'Error:'lf'ADPCM-Player not found !'lf'path to command: '"'%s'"'',PlayADPCM)'"' getcatstr(1,'Quit')
  189.       call Ende
  190.           end
  191.  if Play16DT=1 & ~exists(Play16) then do
  192.           dopus front
  193.           dopus request '"'getcatstr(11,'Error:'lf'Play16 not found !'lf'path to command: '"'%s'"'',Play16)'"' getcatstr(1,'Quit')
  194.       call Ende
  195.           end
  196.  
  197.  if open('input2',Index,'R') ~=1 then exit
  198.  lister set handle busy on
  199.  lister query handle selfiles stem files.
  200.  lister set handle progress files.count getcatstr(12,'Play sound ...')
  201.  lister refresh handle
  202.      
  203.  do i=0 to files.count-1
  204.    lister query handle abort
  205.    if result then leave
  206.    lister set handle progress count i+1
  207.    lister set handle progress name i+1"/"files.count"  "files.i
  208.    Zeile=readln('input2')
  209.    if Zeile="" then leave
  210.    Titel=left(Zeile,pos("@SIZE",Zeile)-2)
  211.    APOS=lastpos("/",Titel)
  212.    if APOS=0 then APOS=lastpos(":",Titel)   
  213.    songname=substr(Titel,APOS+1)
  214.    if songname ~=files.i then do
  215.     i=i-1
  216.     iterate
  217.     end
  218.    if ~exists(Titel) then do
  219.      dopus front 
  220.      dopus request '"'getcatstr(8,'Error:'lf"'%s'"' not found !',Titel)'"' getcatstr(7,'Next')
  221.      iterate
  222.      end
  223.    call DTTEST
  224.    select
  225.      when DT="MP2" then do
  226.          if show('P','Peggy') then do
  227.           address 'Peggy'
  228.           if MPEG=1 then do
  229.            open Titel
  230.            setwindow XOFF 0 YOFF 0 WIDTH 1 HEIGHT 1 XPIC 0 YPIC 0
  231.            Play
  232.            MPEG=2
  233.            end
  234.           else do
  235.            open Titel
  236.            Play async
  237.            Play wait
  238.            end
  239.        end
  240.        else address command PlayMPEG" "MPEGA_OPTIONS" " '"'Titel'"'
  241.      end
  242.    when DT="CDR" then address command Play16 '"'Titel'"' " RAW FREQ=44100 TRACKS=2 BITS=16 INTEL "PL16_OPTIONS
  243.    when DT="WAVE" then address command Play16 '"'Titel'"' " "PL16_OPTIONS
  244.    when DT="AIFF" then address command Play16 '"'Titel'"' " "PL16_OPTIONS
  245.    when DT="ADPCM3" then address command PlayADPCM '"'Titel'"' " NOFILTER"
  246.    otherwise address command Play16 '"'Titel'"' " "PL16_OPTIONS
  247.    end
  248.    address value portname
  249.    lister select handle '"'files.i'"' off
  250.    lister refresh handle
  251.  end
  252.  call close ('input2')
  253.  lister clear handle
  254.  lister clear handle progress
  255.  lister refresh handle
  256.  if exists(Index||'1') then do
  257.         address command 'Delete >NIL: '||Index
  258.         address command 'rename from 'Index||"1"' to 'Index
  259.         iterate
  260.         end
  261.       else leave
  262. end
  263.  
  264. Ende:
  265. address value portname
  266. lister set handle title
  267. lister refresh handle full
  268. lister set handle busy off
  269. lister close handle
  270.  
  271. if show('P','Peggy') & test=2 then do
  272.    address 'Peggy'
  273.    QUIT
  274.    end
  275. address command 'Delete >NIL: '||Index
  276. exit
  277. /*--------------------------------------------------------------------------------*/
  278.  
  279. DTTEST: /*Auf zulässige Sounddatei testen*/
  280. dopus getfiletype '"'Titel'"' id
  281. DT=result
  282. select
  283.   when DT="MP2" then return
  284.   when DT="ADPCM3" then return
  285.   when DT="CDR" then return
  286.   when DT="WAVE" then return
  287.   when DT="VOC" then return
  288.   when DT="AU" then return
  289.   when DT="MAUD" then return
  290.   when DT="AIFF" then return
  291.   when DT="8SVX" then return
  292.   otherwise do
  293.      if DT='RESULT' then DT=getcatstr(13,'not identificed')
  294.      dopus front 
  295.       dopus request '"'getcatstr(6,'Error:'lf'The file '"'%s'"' is filetype '"'%s'"lf'Format not supported !',files.i,DT)'"' getcatstr(7,'Next')
  296.      DT=0
  297.      end
  298. end
  299. return DT
  300.  
  301. /*--------------------------------------------------------------------------------*/
  302. getcatstr:
  303.    parse arg msgno,msgstring,insert.1,insert.2
  304.    if catalog~=0 then msgstring=getcatalogstr(catalog,msgno,msgstring)
  305.    j=0
  306.    do while pos('%s',msgstring)>0
  307.       parse var msgstring fore '%s' aft
  308.       j=j+1
  309.       msgstring=fore||insert.j||aft
  310.       end
  311.    return msgstring
  312.